package com.demo.testtime;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random random = new Random();
        for(long i = 0; i < 1000000; i++) {
            list.add(random.nextInt(9999999));
        }

        long start = System.currentTimeMillis();
        List<Integer> result = list.stream().sorted().collect(Collectors.toList());
        System.out.println(result);
        System.out.println("\ntime1: " + (System.currentTimeMillis() - start));
        start = System.currentTimeMillis();
        result = list.parallelStream().sorted().collect(Collectors.toList());
        System.out.println("\ntime2: " + (System.currentTimeMillis() - start));
    }
}
